<script setup>
import FindPassword from '@/views/findPassword/index.vue'
import { register } from '@/api/auth'
import { ElMessage } from 'element-plus';
import router from '@/router';
import { LOGIN } from '@/router/routeMap';
import { requestErrorHandler } from '@/errorHandler'
import CenterContainer from '@/components/CenterContainer.vue';

const onClickReset = async ({ username, password }) => {
  try {
    const result = await register({ username, password })
    if (result.code === 0) {
      ElMessage.success(result.message)
      router.push(LOGIN)
    }
  } catch (err) {
    requestErrorHandler(err)
  }
}
</script>

<template>
  <CenterContainer :offsetLeft="-20" :offsetTop="-40">
    <FindPassword :onClickReset="onClickReset" />
  </CenterContainer>
</template>